package page;

/**
 * Created by IntelliJ IDEA.
 * User: Evgeniy Krasko
 * Date: 20.11.11
 * Time: 20:50
 */
public class Link {
    private WikiPage from;
    private WikiPage to;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Link link = (Link) o;

        return from.equals(link.from) && to.equals(link.to) ||
                from.equals(link.to) && to.equals(link.from);
    }

    @Override
    public int hashCode() {
        return (from != null ? from.hashCode() : 0) + (to != null ? to.hashCode() : 0);
    }

    public Link(WikiPage from, WikiPage to) {
        this.from = from;
        this.to = to;
    }

    public WikiPage getFrom() {
        return from;
    }

    public WikiPage getTo() {
        return to;
    }

    @Override
    public String toString() {
        return "Link from " +
                from.getTitle() + " " +
                from.getLang() + " to " +
                to.getTitle() + " " +
                to.getLang();
    }
}
